<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>测试defer</title>
</head>
<body>
<button>click</button>
<script src="https://unpkg.com/@reactivex/rxjs@5.0.0-beta.7/dist/global/Rx.umd.js"></script>
<script>
	function doHeavyJob () {
		setTimeout(()=>console.log('i need do something'),2000);
		return true;
	}
	
	Rx.Observable.defer(()=>{
		let result = doHeavyJob();
		return result?'yes': 'no';
	}).subscribe(data => console.log('result:'+data));
</script>
</body>
</html>